package com.gpframework.module.brand.domain.req;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.gpframework.common.utils.StringUtils;
import com.gpframework.module.base.domain.req.BaseReq;
import com.gpframework.module.brand.domain.BrandStoreUserRela;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.util.Date;

/**
 * @ClassName BrandStoreUserRelaReq
 * @Author gpframework
 * @Date 2022-04-11
 * @Version 1.0.0
 * @Description 列表查询信息体
 */
@Data
@ToString
@EqualsAndHashCode
@NoArgsConstructor
@Accessors(chain = true)
public class BrandStoreUserRelaReq extends BaseReq {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("主键")
    private Long storeUserRelaId;
    @ApiModelProperty("品牌id")
    private Long brandId;
    @ApiModelProperty("用户id")
    private Long userId;
    @ApiModelProperty("店铺id")
    private Long storeId;
    @ApiModelProperty("排序")
    private Long sort;
    @ApiModelProperty("备注")
    private String remarks;
    @ApiModelProperty("创建者")
    private String createBy;
    @ApiModelProperty("雇员等级id")
    private Long levelSettingId;
    @ApiModelProperty("雇员等级")
    private String employeesLevel;
    @ApiModelProperty("创建时间")
    private Date createTime;
    @ApiModelProperty("更新者")
    private String updateBy;
    @ApiModelProperty("更新时间")
    private Date updateTime;
    @ApiModelProperty("删除标记;0未删除。1已删除。")
    private Long delStatus;

    /**
     * @Description 生成查询wrapper
     * @Author greatplan@qq.com
     * @Date 2020-11-04 16:04
     * @Param [lqw]
     * @Param [isVO] 是否vo查询体，true的话走的是mapper.xml里面的查询语句，不过查询语法还是mybatis-plus，主要用于某些关联查询出一些非数据表字段
     * @Return void
     */
    public void generatorQuery(QueryWrapper<BrandStoreUserRela> lqw, boolean isVo) {
        String alias = "";
        if (isVo) {
            alias = "gp.";
            lqw.eq(alias + "del_status", 0);
        }
        if (this.getStoreUserRelaId() != null) {
            lqw.eq(alias + "store_user_rela_id", this.getStoreUserRelaId());
        }
        if (this.getBrandId() != null) {
            lqw.eq(alias + "brand_id", this.getBrandId());
        }
        if (this.getUserId() != null) {
            lqw.eq(alias + "user_id", this.getUserId());
        }
        if (this.getSort() != null) {
            lqw.eq(alias + "sort", this.getSort());
        }
        if (StringUtils.isNotBlank(this.getRemarks())) {
            lqw.eq(alias + "remarks", this.getRemarks());
        }
        if (StringUtils.isNotBlank(this.getCreateBy())) {
            lqw.eq(alias + "create_by", this.getCreateBy());
        }
        if (this.getLevelSettingId() != null) {
            lqw.eq(alias + "level_setting_id", this.getLevelSettingId());
        }
        if (StringUtils.isNotBlank(this.getEmployeesLevel())) {
            lqw.eq(alias + "employees_level", this.getEmployeesLevel());
        }
        if (this.getCreateTime() != null) {
            lqw.eq(alias + "create_time", this.getCreateTime());
        }
        if (StringUtils.isNotBlank(this.getUpdateBy())) {
            lqw.eq(alias + "update_by", this.getUpdateBy());
        }
        if (this.getUpdateTime() != null) {
            lqw.eq(alias + "update_time", this.getUpdateTime());
        }
        if (this.getDelStatus() != null) {
            lqw.eq(alias + "del_status", this.getDelStatus());
        }
        lqw.orderByDesc(alias + "update_time");
    }
}
